import { Route, NavLink } from 'react-router-dom';
import {LoginPage} from "../../view/LoginPage";
import {ManagePage} from '../../view/ManagePage';
import {UserPage} from '../../view/UserPage';
import { Menu } from "antd";

const index = [
    {
        path: '/LoginPage',
        component: LoginPage,
        title: '登录',
        show: true
    }, {
        path: '/ManagePage',
        component: ManagePage,
        title: '管理员',
        show: true
    },
     {
        path: '/UserPage',
        component: UserPage,
        title: '用户',
        show: true
    }
]

const indexRoutes = () => {
    return index.map(({ path, component }, i) => {
        return <Route key={i} path={path} component={component} />

    })
}

const indexMenu = () => {
    return (
        <>
            {index.map(({ path, title, show }, i) => {
                if (!show)
                    return
                return (
                    <Menu.Item key={i}>
                        <NavLink key={i} to={path}>{title}</NavLink>
                    </Menu.Item>
                )
            })}
            {/* <Avatar /> */}
        </>
    )
}

export { indexRoutes, indexMenu }